home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSUNIX.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-07
|
4KB
|
151 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bsunix.c
// Title: Base library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains code for run-time library functions which are not
// found on SCO UNIX.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
#if OS_UNIX
//----------------------------------------------------------------------------
// Description: Replacement for memcmp function
// Parameters: See C RTL docs
// Returns: See C RTL docs
//----------------------------------------------------------------------------
int memcmp(const void *__s1, const void *__s2, size_t __n)
{
PBYTE pb1 = (PBYTE)__s1;
PBYTE pb2 = (PBYTE)__s2;
for ( ; __n; --__n, ++pb1, ++pb2)
if (*pb1 > *pb2)
return 1;
else if (*pb1 < *pb2)
return -1;
return 0;
}
//----------------------------------------------------------------------------
// Description: Replacement for stricmp function
// Parameters: See C RTL docs
// Returns: See C RTL docs
//----------------------------------------------------------------------------
int stricmp(const char *s1, const char *s2)
{
for (; ; s1++, s2++)
{
CHAR ch1 = (CHAR)toupper(*s1);
CHAR ch2 = (CHAR)toupper(*s2);
if (ch1 > ch2)
return 1;
else if (ch1 < ch2)
return -1;
if (ch1 == '\0' && ch2 == '\0')
return 0;
}
return 0;
}
//----------------------------------------------------------------------------
// Description: Replacement for strnicmp function
// Parameters: See C RTL docs
// Returns: See C RTL docs
//----------------------------------------------------------------------------
char *strlwr(char *s1)
{
char *s2 = s1;
for (; *s1; s1++)
*s1 = (CHAR)tolower(*s1);
return s2;
}
//----------------------------------------------------------------------------
// Description: Replacement for strnicmp function
// Parameters: See C RTL docs
// Returns: See C RTL docs
//----------------------------------------------------------------------------
int strnicmp(const char *s1, const char *s2, size_t maxlen)
{
for (; maxlen; maxlen--, s1++, s2++)
{
CHAR ch1 = (CHAR)toupper(*s1);
CHAR ch2 = (CHAR)toupper(*s2);
if (ch1 > ch2)
return 1;
else if (ch1 < ch2)
return -1;
if (ch1 == '\0' && ch2 == '\0')
return 0;
}
return 0;
}
//----------------------------------------------------------------------------
// Description: Replacement for strnicmp function
// Parameters: See C RTL docs
// Returns: See C RTL docs
//----------------------------------------------------------------------------
char *strupr(char *s1)
{
char *s2 = s1;
for (; *s1; s1++)
*s1 = (CHAR)toupper(*s1);
return s2;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------
#endif // OS_UNIX